﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using S1.Models;

namespace S1._1_2.ViewModels
{
    public class MainWindowViewModel : ViewModelBase
    {
        public MainWindowViewModel()
        {
            Products = new ObservableCollection<Product>();
            _addCommand = new RelayCommand(AddNewProduct);

        }

        private void AddNewProduct()
        {
            Products.Add(new Product
            {
                 Active=true,
                  Category="分类",
                   Cost=0,
                    Price=10,
                     ProductName="面包"
            });

        }

        private string _search;

        public string Search
        {
            get { return _search; }
            set
            {
                _search = value;
                OnPropertyChanged();
            }
        }

        //所有按钮包括菜单，点击。MVVM模式，，Command
        private ICommand _addCommand;

        public ICommand AddCommand
        {
            get { return _addCommand; }
            set
            {
                _addCommand = value;
            }
        }

        private ObservableCollection<Product> _products;

        public ObservableCollection<Product> Products
        {
            get { return _products; }
            set
            {
                _products = value;
            }
        }
    }
}
